package com.chexiehui.jc.mvp.mine;

import com.chexiehui.jc.base.ApiCallback;
import com.chexiehui.jc.base.BaseModel;
import com.chexiehui.jc.base.BasePresenter;

/**
 * @Description 浏览历史
 * @Auth SongJun
 * @Date 2019/11/20 10:05
 **/
public class BrowseHistoryPresenter extends BasePresenter<BrowseHistoryCovenant.View, BrowseHistoryCovenant.Stores>
        implements BrowseHistoryCovenant.Presenter {

    public BrowseHistoryPresenter(BrowseHistoryCovenant.View view) {
        attachView(view);
    }

    @Override
    public void onDoDelete(int type) {
        mvpView.showLoading("正在清空");
        addSubscription(appStores.onDoDelete(type),
                new ApiCallback<BaseModel<Object>>(mvpView) {
                    @Override
                    public void onSuccess(BaseModel<Object> model) {
                        if (model.getResultCode() == 0) {
                            mvpView.hide();
                            mvpView.onDoDeleteSuccess(model);
                        } else {
                            onFailure(model.getResultCode(), model.getResultInfo());
                        }
                    }

                    @Override
                    public void onFailure(int code, String msg) {
                        mvpView.hide();
                        mvpView.onDoDeleteFailure(new BaseModel<>(code, msg));
                    }
                });
    }

}